<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <link rel="import" href="indexs.html" id="page1">

    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<script type="text/javascript">
    document.write(page1.import.body.innerHTML);
</script>
<!-- 示例-970 -->
<ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>
<div class="layui-row">
    <div class="layui-col-xs5" style="font-size: 20px; margin-left: 200px;">
        <img src="image/71843cbde75bb01b4290011d457552fd.jpg" class="layui-nav-img " style="width: 60px; height: 56px;">
        <button type="button" class=" selet_file layui-btn layui-btn-xs layui-btn-normal layui-col-xs5" id="test1" style="float: right; margin-top: 10px; margin-right: 70px; width: 55px;">修改头像</button>
    </div>
</div>
<br>
<div class="layui-row" id="showStudent">
    <!--<div class="layui-form-item layui-col-xs12">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-block" style="margin-top: 9px;">
            <input type="text" name="sName" placeholder="请输入昵称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-block">
            <input type="text" name="sAddress" placeholder="请输入地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">个性签名</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" name="sIntroduction"></textarea>
        </div>
    </div>-->

</div>
<div class="layui-form-item">
    <div class="layui-input-block">
        <!-- <button class="layui-btn" lay-submit lay-filter="demo1" id="updates">修改信息</button>-->
        <button type="button" class="layui-btn layui-btn-normal" id="updates">修改信息</button>
    </div>
</div>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/jquery.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    $(function () {
        var file;
        file = $('<input type="file" />');

        $('.selet_file').click(function () {
            file.click();
        });
        file.change(function (e) {
            var selet_file = file[0].files[0];
        })
    })

    layui.use(['form'],function () {
        var form = layui.form;
        form.on('submit(demo1)',function (data) {
            $.ajax({
                url:"CoachData/updateData",
                data:{
                    tId:1,
                    tName:$("#tName").val(),
                    tAddress:$("#tAddress").val(),
                    tIntroduction:$("#tIntroduction").val()
                },
                success:function (data) {
                    alert("修改成功");
                }
            })
        })
    })

    /* layui.use(['form'],function () {
         var form = layui.form;

         //表单初始赋值
         form.val('example', {
             "sName": "贤心" // "name": "value"
             ,"sAddress": "123456"
             ,"sIntroduction": 1
         })
     })
*/
    $("#updates").on('click',function () {
        layer.open({
            type:1,
            area:['800px','600px'],
            shadeClose:false,
            content:'<form class="layui-form" action="" lay-filter="example">\n' +
                '    <br>\n' +
                '   <div class="layui-row">\n' +
                '    <div class="layui-form-item layui-col-xs12">\n' +
                '        <label class="layui-form-label">昵称</label>\n' +
                '        <div class="layui-input-block" style="margin-top: 9px;">\n' +
                '            <input type="text" name="tName" placeholder="请输入昵称" value="'+$("#tname").html()+'" autocomplete="off" class="layui-input" id="tName"/>\n' +
                '        </div>\n' +
                '    </div>\n' +
                '    <div class="layui-form-item">\n' +
                '        <label class="layui-form-label">地址</label>\n' +
                '        <div class="layui-input-block">\n' +
                '            <input type="text" name="tAddress" placeholder="请输入地址" value="'+$("#taddress").html()+'" autocomplete="off" class="layui-input" id="tAddress">\n' +
                '        </div>\n' +
                '    </div>\n' +
                '\n' +
                '    <div class="layui-form-item layui-form-text">\n' +
                '        <label class="layui-form-label">个性签名</label>\n' +
                '        <div class="layui-input-block">\n' +
                '            <textarea placeholder="请输入内容" class="layui-textarea" name="tIntroduction" id="tIntroduction">'+$("#tintroduction").html()+'</textarea>\n' +
                '        </div>\n' +
                '    </div>\n' +
                '\n' +
                '    <div class="layui-form-item">\n' +
                '        <div class="layui-input-block">\n' +
                '            <button class="layui-btn" lay-submit lay-filter="demo1" id="submit">确认修改</button>\n' +
                '        </div>\n' +
                '    </div>\n' +
                '    </div>\n' +
                '   </form>'

        });
    });

    $(function () {
        $.ajax({
            url:"CoachData/showData",
            data:{
                tId:1
            },
            success:function (data) {
                var content="";
                for (var i =0; i < data.length; i++){
                    content+='<div class="layui-form-item" style="margin-left: 300px">\n' +
                        '        <label class="layui-form-label">昵称</label>\n' +
                        '        <div class="layui-input-block">\n' +
                        '            <label id="tname">'+data[i].tName+'</label>\n' +
                        '        </div>\n' +
                        '    </div>\n' +
                        '    <div class="layui-form-item" style="margin-left: 300px">\n' +
                        '        <label class="layui-form-label">地址</label>\n' +
                        '        <div class="layui-input-block">\n' +
                        '           <label id="taddress">'+data[i].tAddress+'</label>\n' +
                        '        </div>\n' +
                        '    </div>\n' +
                        '    <div class="layui-form-item layui-form-text" style="margin-left: 300px">\n' +
                        '        <label class="layui-form-label">个性签名</label>\n' +
                        '        <div class="layui-input-block">\n' +
                        '           <label id="tintroduction">'+data[i].tIntroduction+'</label>\n' +
                        '        </div>\n' +
                        '    </div>'
                }
                $("#showStudent").html(content);
            }

        })
    })



</script>

</body>
</html>